package offer;

public class Solution63 {
    public int maxProfit(int[] prices) {
        int res = 0, min = prices.length > 0 ? prices[0] : 0;
        for (int price : prices) {
            res = Math.max(res, price - min);
            min = Math.min(min, price);
        }
        return res;
    }
}
